package com.example.shutdown_v1.entity;

import jakarta.persistence.*;
import lombok.Data;
import java.time.LocalDateTime;

/**
 * 每日巡检记录实体
 * 对应数据库表: daily_inspection_record
 */
@Data
@Entity
@Table(name = "daily_inspection_record", indexes = {
    @Index(name = "idx_shop_inspection_time", columnList = "shop_id,inspection_time"),
    @Index(name = "idx_inspection_time", columnList = "inspection_time")
})
public class DailyInspectionRecord {
    
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;
    
    @Column(name = "shop_id", nullable = false)
    private Long shopId;
    
    @Column(name = "inspection_time", nullable = false)
    private LocalDateTime inspectionTime;
    
    @Column(name = "total_sensors")
    private Integer totalSensors;
    
    @Column(name = "closed_sensors")
    private Integer closedSensors;
    
    @Column(name = "open_sensors")
    private Integer openSensors;
    
    @Column(name = "unknown_sensors")
    private Integer unknownSensors;
    
    @Column(name = "offline_sensors")
    private Integer offlineSensors;
    
    @Column(name = "is_compliant")
    private Boolean isCompliant;
    
    @Column(name = "unclosed_sensor_list", columnDefinition = "TEXT")
    private String unclosedSensorList;
    
    @Column(name = "result_summary", columnDefinition = "TEXT")
    private String resultSummary;
    
    @Column(name = "created_at")
    private LocalDateTime createdAt;
    
    @PrePersist
    protected void onCreate() {
        createdAt = LocalDateTime.now();
    }
}

